﻿using MongoDB.Driver;
using Sustainalytics.DataLayer.Shared;
using Sustainalytics.Entities;
using System;
using System.Collections.Generic;
using System.Linq;

namespace Sustainalytics.ClientDW.DataAccessLayer
{
    public class GovernanceRepository : RepositoryCollection<GovernanceCompanyProfile>, IGovernanceRepository
    {
        public GovernanceRepository(string cnxString) : base(cnxString)
        {
        }

        public static IGovernanceRepository GetInstance(string connectionString)
        {
            return new GovernanceRepository(connectionString);
        }

        public IMongoDatabase GetDb()
        {
            return base.Collection().Database;
        }

        public GovernanceCompanyProfile ReadByCompanyId(Guid companyId)
        {
            return base.ReadAllWhere(x => x.Id == companyId).FirstOrDefault();
        }

        public GovernanceCompanyProfile ReadById(Guid id)
        {
            return base.Read(id);
        }

        public void Update(GovernanceCompanyProfile gProfile)
        {
            base.Update(gProfile.Id, gProfile);
        }

        void IGovernanceRepository.Delete(Guid id)
        {
            base.Delete(id);
        }
    }
}
